package br.kanban.core.busines;

import java.io.Serializable;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

public abstract class GenericBO<T extends Serializable> {

	@PersistenceContext(unitName="KanbanDS")
	private EntityManager em;
	
	public T insert(T obj){
		em.persist(obj);
		return obj;
	}
	
	public T update(T obj){
		return em.merge(obj);
	}
	
	public void delete(T obj){
		em.remove(em.merge(obj));
	}
	
	public EntityManager getEm() {
		return em;
	}

	public void setEm(EntityManager em) {
		this.em = em;
	}
	
	public abstract List<T> pesquisar(T filtro);
}
